/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-11-03
 * Time: 19:55
 */
class Solution9 {
    public ListNode deleteNode(ListNode head, int val) {
        ListNode newHead = new ListNode();
        newHead.next = head;
        ListNode cur = newHead;
        while(cur.next != null) {
            if(cur.next.val == val) {
                cur.next = cur.next.next;
                break;
            }else {
                cur = cur.next;
            }
        }
        return newHead.next;
    }
}
